package com.zbkj.common.invoice;

import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @Auther:
 * @Date: 2024/8/26 17:25
 * @Description:
 */
@Setter
@Getter
public class InvoiceToExcel {

    private String name;
    private String model;
    private String unit;
    private BigDecimal count;
    private BigDecimal price;
    private BigDecimal amount;
    private BigDecimal taxRate;
    private BigDecimal taxAmount;

    //发票总信息
    private String title;
    private String code;
    private String number;
    private String date;
    private String buyerName;
    private String sellerName;
    //发票合计-amount
    private BigDecimal totalAmount;
    //合计税额 -taxAmount
    private BigDecimal totalTaxAmount;
    //价税合计 -totalAmount
    private BigDecimal totalptAmount;

    public static List<InvoiceToExcel> invoiceToExcelList(Invoice invoice) {
        List<InvoiceToExcel> list = new ArrayList<>();
        for (Detail detail : invoice.getDetailList()) {
            InvoiceToExcel ite = new InvoiceToExcel();
            BeanUtils.copyProperties(detail,ite);
            ite.setTitle(invoice.getTitle());
            ite.setCode(invoice.getCode());
            ite.setNumber(invoice.getNumber());
            ite.setDate(invoice.getDate());
            ite.setBuyerName(invoice.getBuyerName());
            ite.setSellerName(invoice.getSellerName());
            ite.setTotalAmount(invoice.getAmount());
            ite.setTotalTaxAmount(invoice.getTaxAmount());
            ite.setTotalptAmount(invoice.getTotalAmount());
            list.add(ite);
        }
        return list;
    }
}
